<?php
class Model_User extends Zend_Db_Table_Abstract{
	public $_name = "user";
	public $_primary = "iduser";
	
        public function getAll()
        {
            $se=  $this->select();
            $se->order("iduser desc");
            return $this->fetchAll($se)->toArray();
        }
        public function getwhereiduser($iduser)
        {
            $se=  $this->select();
            $se->where("iduser ='?'",$iduser);
            return $this->fetchAll($se)->toArray();
        }
	public function getWhere($u,$p){
		$se = $this->select();
		$se->where("username = ?",$u);
		$se->where("password = ?",$p);
		if($this->fetchRow($se))
			return $this->fetchRow($se)->toArray();
		else
			return false;
	}
        public function getWhereUser($username){
		$se = $this->select();
		$se->where("username = ?",$username);
		if($this->fetchRow($se))
			return true;
		else
			return false;
	}
        public function getWhereEmail($email){
		$se = $this->select();
		$se->where("email = ?",$email);
		if($this->fetchRow($se))
			return true;
		else
			return false;
	}
        public function insertUser($data){
		$kq = $this->insert($data);
		if($kq)
			return true;
		else
			return false;
	}
        public function getUnlock()
        {
            $se=  $this->select();
            $se->where("trangthai='0'");
            return $this->fetchAll($se)->toArray();
        }
        public function getLock()
        {
            $se=  $this->select();
            $se->where("trangthai='2'");
            return $this->fetchAll($se)->toArray();
        }
        public function getUnlockcount()
        {
            $se=  $this->select();
            $se->where("trangthai='0'");
            $usr= $this->fetchAll($se)->toArray();
            return count($usr);
        }
        public function setLock($data,$iduser)
        {
            $kq = $this->update($data,"iduser=$iduser");
            if($kq){
			return true;
            }
            else{
			return false;
            }
        }
        public function setUnlock($data,$iduser)
        {
            $kq = $this->update($data,"iduser=$iduser");
            if($kq){
			return true;
            }
            else{
			return false;
            }
        }
}
?>